
clear
do "...\First.do"
*************************************************

clear 
use "$raw\lung_cancer_test2_moreyears.dta"

g year=year(d_odto)
drop d_odto
drop c_opr
drop recnum

g lungscan=1

bys pnr: egen min=min(year)
g first_lung=(min==year)
keep pnr year lungscan first_lung

duplicates drop
save "$work\lung_scans.dta", replace